home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.19980901-19981211
/
000237_news@newsmaster….columbia.edu _Wed Oct 28 17:00:08 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
4KB
Return-Path: <news@newsmaster.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id RAA10180
for <kermit.misc@watsun.cc.columbia.edu>; Wed, 28 Oct 1998 17:00:08 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id RAA13286
for kermit.misc@watsun; Wed, 28 Oct 1998 17:00:07 -0500 (EST)
Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: sending variables on the command line
Date: 28 Oct 1998 22:00:06 GMT
Organization: Columbia University
Lines: 88
Message-ID: <718456$a8l$1@apakabar.cc.columbia.edu>
References: <71810c$31v$1@supernews.com>
NNTP-Posting-Host: watsun.cc.columbia.edu
Xref: news.columbia.edu comp.protocols.kermit.misc:9437
In article <71810c$31v$1@supernews.com>, Michael Rose <mike@tegris.com> wrote:
: I have a script that I would like to send variables from the command prompt.
:
: kermit script-name variable1 variable2 variable3 variable4
:
Let's assume you are talking about C-Kermit 6.0.
: $kermit maillogs 10.2.2.14 joebloe joepasswd maillog
:
This can't work because "10.2.2.14", "joebloe", "joepasswd", and "maillog"
are not valid C-Kermit command-line arguments.
: Any help would be greatly appreciated.
:
The trick that you are looking for is documented, somewhat obscurely,
on pages 353, 383, 469, and 513 of "Using C-Kermit", 2nd edition:
1. If you put an "=" sign (surrounded by whitespace) on the command line,
the following words are ignored, but still assigned to the argument
vector array, \&@[].
2. You can use a FOR loop to loop through the argument vector array
elements until you find the one whose value is "=".
3. The ones after that are your variables.
Example:
$kermit maillogs = 10.2.2.14 joebloe joepasswd maillog
(note insertion of "=" sign)
The maillogs script can retrieve the arguments as follows:
local \%i \%k
for \%i 0 \v(args)-1 1 {
xif equal "\&@[\%k]" "=" {
assign \%k \%i
increment \%k
break
}
}
At this point, if \%k is defined, it is the index of your first variable:
\&@[\%k] is 10.2.2.14
\&@[\%k+1] is joebloe
\&@[\%k+2] is joepasswd
\&@[\%k+3] is joepasswd
\&@[\%k+4] is maillog
Granted, this is obscure, nonintuitive, and cryptic. The next version
of C-Kermit will include a much better way to access these variables:
within the script, you will be able to refer to these variables like this:
\%0 = the name of the script file (maillogs)
\%1 = the first argument after "=" (10.2.2.14)
\%2 = the second argument after "=" (joeblow)
and so on. (This feature is not in C-Kermit 6.1 Beta.05; it will be in
7.0 Alpha.01 and in the next release of K-95 -- watch this space for
announcements.)
By the way, the reason for the "=" is to allow a mixture of arguments to
Kermit and arguments to the script on the same command line. Thus, both
examples above would work just as well if your command line was:
$kermit maillogs -i -Q -Y -H = 10.2.2.14 joebloe joepasswd maillog
And finally, note that you can remove the word "kermit" from the command line
if you first:
chmod +x maillogs
and put:
#!/usr/local/bin/kermit
as the first line (substitute the actual pathname of the Kermit executable).
Now you can just run the script as if it were a shell script (except that
you still need the "=" to precede the argument list):
$maillogs = 10.2.2.14 joebloe joepasswd maillog
See p.513 for details.
- Frank